Yes wearing a bra can help to prevent sagging breasts but you need to wear a proper supporting sports bra to help keep the breasts from sagging.
When breasts are allowed to hang loose they start to sag.
If you have sagging breasts you can also do some chest exercises to firm up and lift your breasts back to where they were before.