Being a solid fruit, pineapples have the potential of being carved.
My guess would be that the pineapple had fallen from a tree and washed out into the ocean. There it sunk, and landed on it's side. Sponge bob or whomever the pineapple's previous home owner was happened upon it, and hired workers to excavate the interior of the fruit.
The workers probably used special measuring tools to cut the inside of the pineapple into a square shape. It must not have occurred to them that carving the fruit in a circle would have given the home a minimally larger interior.
In conclusion, having been carved in a cube like fashion, the pineapple's surface area resembles a suburban home.
However, having thought your question through, I realize it brings up many more inexplicable occurrences in Sponge Bob's abode. For example, how is it that the pineapple is hallow, yet it doesn't float? And how were the walls plastered, when in order for cement to dry, oxygen must be present?