Ditto G-Cam, but let me add an additional comment.
As G-Cam says, "only the X", means that there are several things under discussion, but right now the one we are interested in is the X.
"The only X" says that there is only one thing that qualifies as X.
In your example, talking about the "second square", the second usage doesn't make much sense. Presumably there is only one square that is "second". I wouldn't suppose there could be 5 or 10 "second squares".
But suppose I said something about the "red square". If I said, "Consider the only red square", that would mean that while there may be many squares, only one of them is red. I am emphasizing that there is only one red square.
"Consider only the red square" says that I am calling your attention to the square that is red. The fact that I use the singular "square" implies that there is only one, but the sentence structure is not emphasizing that there is only one, but rather assumes this, and then emphasizes that this is the one we are interested in.