I would do two things here. Firstly, check the movement of the pistons. If only one is moving, it may need a little help. You can use a firm plastic or large flat head screwdriver to press on the affected piston to try and align it. Push the moving one back in as far as it will go.
Once you get some movement out of it, it’s worth getting some lubrications over the piston to help the rubber o-ring keep a seal and slide within the calliper body. I’m assuming hydraulic brakes here.
Make sure pads and discs are well away from any lubricant as you do this. You probably don’t want a solvent-based lube here either. If your brakes use mineral oil like Shimano use, that oil is perfectly fine to use. I’ve used chain line in the past. Let it soak over the piston and give it a good clean with a rag afterwards.
Once things are moving again, you should re-centre you calliper against the disc. With the pistons pushed back and pads and wheel re-fitted, loosen the bolts holding the calliper to the frame. Squeeze the brakes until they feel like normal braking and check that the disc is close to central in the calliper. If it is,
Whilst holding the brake lever on, nip the bolts up enough to keep the calliper in place and then tighten to the correct torque once you’ve released the brake.
You shouldn’t hear the brake rubbing on the pads as you spin the wheel. If you get an intermittent rub, your rotor may be slightly bent but that’s the subject of another thread.