The idea is simple. You want to make boxes.
When a box is formed, whoever drew the 4th side gets the box. The box is filled in with their color. Red for you, blue for Mr. MagicPants. Every time a box is made, the player goes again until no more boxes can be finished with a single line.
When you try to make squares, you can start anywhere, even on a line drawn by Mr. MagicPants. Mr. MagicPants can do the same. That's the key. Never draw the third line on a square unless you have to, because Mr. MagicPants will draw the 4th, get the square, and go again.