Like anything else with a basis in mythology, it can be "a little tricky" to pin down exactly what a gnome should be.
Alchemy and related traditions used the term to refer to a form of earth elemental, and more generally they seem to have been regarded as a form of (generally subterranean) spirits or fae similar to dwarves. Alternatively they may be "seelie" counterparts to goblins and/or gremlins - personifications of honest craftsmanship and productive labour.
Indeed, the dwarf/gnome boundary indistinct in many traditions - gnomes are perhaps more likely to be found near the surface and may work with less "industrial" crafts than the dwarves - but are otherwise hard to distinguish from them. Into the modern era, the gap widens, with gnomes often being brought out of the ground altogether to become forest dwellers or urban tinkerers, sometimes specialising in light hearted japes and illusion magic (in the face of the dour, non-magical dwarves), or engaging in artifice or spinning out clockpunk (or even steampunk) equivalent technology1. Sometimes all at once.
"Certain RPGs" have taken the "new gnome" to such extents that their "cheery little chappie" toymakers with a love of entertaining and an innate ability to talk to animals are effectively unbearable.