The reason he said this was because he didn't like religious nuts. You know the type…the TV preachers that are always trying to scoop attention on to themselves. He didn't want you to pray to let people know that you were a bandwagon jumper and a "LOOK AT ME! I AM BETTER THAN YOU!!!" type of human.
Remember the Pharisees and Sadducees? These religious nuts murdered Jesus because he was exposing them as hypocrites. These guys stood in front of the town and acted like they were holier than the rest of the people and Jesus trolled them at every chance he could get.
Remember anon, what he was saying was don't talk about it, BE about it.
When you pray in secret, you can do it and be real without having to church it up with a bunch of thees and thous to impress your peers. It isn't a pissing contest and if it is it isn't real prayer…..more like preyer.