Sometimes if the brake has been bled previously when the pads are slightly worn it will be impossible to push back the pads/pistons unless you release some fluid.
This is fine, but always release fluid from the lever (highest point in the system). Opening the calliper to release fluid is more likely to introduce air into the system.
The pads need to be pushed all the way back before you attempt to reinstall your wheel/rotor. Then it’s just a case of realigning your calliper over the rotor to prevent rubbing.
If you have a spongy lever at this point it may be that you’ve released too much fluid and a bleed of the system will be required.