Several reasons why your idea won't - and cannot - work. First of all, you have to have a very, very bad general if he allows his phalanx(es) being attacked in the rear. So bad, that if he survives the battle, he'll be very likely murdered by his surviving troops or executed by his government. People will wonder how much the enemy paid him for his services.
A phalanx is a (a kind of) unit. An army usually had several of them. Also skirmish units, archers and cavalry and other units. The job of those troops is to make sure that attacks from the rear don't happen.
You need a very good general to get out of that mousetrap. Caesar got himself into that predicament in Thapsus. He was surrounded on a peninsular on both ends. He got out of it, but made damn sure that never ever happened again under his command.
Next, as has already been stated - turning around will not work. Everybody got less room to fight. You're squeezed into not being able to do anything. Not even wield a sword to defend yourself. This was essentially what Hannibal did to the Romans at Trasimene and Cannea.
Phalanxes weren't the only formation with that particular problem. Almost all formations have their pro's and cons. The Romans didn't use phalanxes at Trasimene, Cannea and Thapsus, but they were squeezed in nevertheless.
You also wonder why nobody wore a shield on the left side. I am left handed, but when I started epee fencing, I noticed I am right handed for that. It's usually a mistake to force people to do the other thing. Left handed writers can learn to write right handed, but usually have a lousy handwriting. And vice versa. I can do calligraphy with my left hand, and learned right hand writing - which is barely readable. About the level of a first grader.
Same applies to fighting. You can train yourself to fight right handed, but you'll never be really good at it. TheyThe soldiers no doubt passed the requirements, otherwise they wouldn't be in a phalanx or a legion. I doubt if they were much better than the basic requirements.
Next, not that many people are left handed by nature. About 10%, I read. That's not a lot to start working with. The other 90% would be equally bad when trained left handed. So the obvious and better solution was to have a different unit cover the left flank. That's where a.o. cavalry and light infantry comes into play.