Astronauts do really wear diapers.
An astronaut wears a diaper during liftoff into space, during return from space and while in their space suits for the 8 to 10 hours.
However if the astronaut is in the ISS or International Space Station they don't have to wear diapers and can use a toilet designed for use in space.
But when wearing the space suits and when landing and taking off the astronauts do wear the diapers.
NASA calls the adult diaper a maximum absorbency garment or (MAG) although it's just an adult diaper.
A Maximum Absorbency Garment (MAG) is an adult-sized diaper with extra absorption material that NASA astronauts wear during liftoff, landing, and extra-vehicular activity (EVA) to absorb urine and feces.
It is worn by both male and female astronauts.
Astronauts wear diapers when stuck in their spacesuits for 8 to 10 hours while on an EVA, during launch, and landing.
The time required to take a spacesuit off to go to the bathroom would cause more problems than wearing a diaper.
Each spacewalking astronaut wears a large, absorbent diaper called a Maximum Absorption Garment (MAG) to collect urine and feces while in the space suit.
The astronaut disposes the MAG when the spacewalk is over and he/she gets dressed in regular work clothes.