I'm presuming you're presently learning about electrostatic potential energy. You approach the problem by imagining assembling the square charge by charge in "empty space". The first charge can come in for free, since there's nothing else around. The second charge comes in from infinity down to a distance r from the first charge. Recall the relationship between work done on that second charge and the value of the final potential energy between the two charges.
You then continue this by placing the third charge at one of the remaining corners of the square, then finally placing the fourth charge at the vacant vertex. Each additional does not affect the results from the previous stages; the total work done will just be the sum for each of these three steps.