Holding in your pee or urine does help somewhat to strengthen your bladder and bladder muscles so it can prevent urinary incontinence in the future but sometimes holding in your pee for 10 or 20 minutes before going pee.
However do not hold in your pee or urine too long or too often though as it can lead to kidney failure and other bladder infections which can be worse than having a weak bladder.
I would rather deal with a weak bladder and have urinary incontinence instead of having a bladder infection or possible kidney failure.
Having kidney failure will eventually kill you but having incontinence is not as bad.
When you do hold your pee it helps your bladder muscles strengthen which allows you to hold in your pee a bit longer when you need too.
But if you do need to go pee you should pee as soon as possible because it's not safe to hold in pee for too long.