>>10830302I mean, do you understand why a continuous bijection between compact hausdorff spaces is a homeomorphism? Since it sends closed sets to compact ones, which are thus closed.
So your bijection from the unit square to the unit interval would have to tear apart a closed square contained within, and then assemble it into a nice closed set in the unit interval. But it's got uncountably many little segments to do this with, and they can't overlap (if they do on the ends, just make the square you're looking at a bit smaller and this holds). Well, each one is not a point, so it'll contain it's own rational. And you're toast. That's just an intuitive argument, but really it should be clear enough that a line segment is not homeomorphic to a square since you can remove a point from one to disconnect it but not from the other. In fact that's another great argument as to why the unit interval can't continuously biject the square, if you pop out the point at the middle of the line then your whole square falls into 2 parts!
On the other hand, in the surjective case this is okay because other parts of the line can just fill in that hole in the image and hold it together. Or something like that. It should really be intuitive that you can make a line spin around your square a whole bunch "until it fills it in", and then you can just fit the endpoints of the line in the square somewhere. Remember you can stretch out the open interval in the middle as long as you'd like, so this shouldn't be a problem.
If you're not thinking about topology in this sort of intuitive geometric way, I'd recommend working through more of these counterexample style problems and seeing how you can best visualize them. For instance, why isn't the 2-sphere homeomorphic to a subset of R^2? In the most intuitive way you can muster.