I'd suggest always changing the brakes on the same axle at the same time. Especially if one was damaged or malfunctioning.
It's best to do them all at once, but necessary to do all on the same axle at once.
Why? It is critical both sides are evenly balanced and provide even braking. Ideally, all axles and wheels would brake evenly, but not as dangerous as one side pulling unevenly, which can lead to sway and unstable handling.
Besides, they aren't that much, just be sure not to install them backwards (happens more than you'd think).
Glad you found your problem before you had serious damage or troubles.