How?? Many small solenoids like that are made with the coil being "one size fits all", to get enough bobbin space in a small diameter to get enough pull in force. They then put a stop in the bottom of the coil for things not needing the full movement. That makes the part work in many applications without the need of the same number of bobbin sizes.The rivet at the bottom is there to prevent sticking caused by residual magnetism. Other solenoid types use other mechanisms.
Kind of like some IC's that only need so many active pins that are put in a package that has extra pins that are then called out as NC, no connection. Saves making many odd sized molds to put on the plastic and making odd ball pin sockets.

