While this may seem convenient, it often causes problems, particularly with heavy or dangerous items. However, in most cases these problems can be mitigated by proper application of the pickup_types and pickup_burden options.
To toggle autopickup, you can select it from the Options menu or press '@'.
If pickup_types is left as all, then autopickup can be used whenever it is necessary to pick up items on a teleport trap or hole (for example, in Sokoban) where the player would otherwise not have a chance to pick up the items before being whisked away. Pickups caused by autopickup take place in the same turn as the movement (which is not possible without autopickup), so it can be used to pickup items saving a turn, which is useful if you are fleeing or doing a speed ascension.
It is possible to refine autopickup options even further with autopickup_exceptions, but this feature is still in experimental stages and may have some bugs.