as the S21 Ultra has a max charging of 25W, that is the max speed it will charge at. I have a 45W charger from my S20 Ultra, so I can use it but it won't charge faster than the 25W the phone accepts.
You are perfectly safe using the 45W charger from Samsung, or any other charger that has the PD (Power Delivery) standard built in. This standard figures out the fastest it can charge, and only delivers the applicable voltage. This is all a technical way of saying the if it has PD, it will NOT provide more power than the device can handle.