Not everyone does.
But the idea is to release the gas bubbles that have nucleated on the inside surface of the can, so the bubbles float to the top and pop.
If there are numerous bubbles already formed on the inside of the can, when the pressure in the can is released, these bubble grow in size immediately, becoming many times their previous size.
At the same time, they act as surface area for more carbon dioxide gas to form, making the bubble bigger still.
If enough of the now large bubbles form low in the can, they make the contents of the can (the soda inside) increase in volume, causing it to spill out of the can.
If the top of the can has not been quickly and fully opened, a stream of bubbly soda can shoot out of the narrow opening, making a sticky mess, usually in the direction of the person opening the can.
Tapping on the can, or setting it on the table with a thump, will dislodge the bubbles from the inner side of the can, where they accumulate at the top and break. Now when the can is opened, only the gas escapes from the initially small opening. The gas makes much less of a mess when it hits the face of the person looking for a cool drink.