I don’t know that he was saying never pray publicly, just don’t do it if you are only doing to be seen doing it.
Even so, that is what they were doing; or if it was not, it is unclear that it was not. Which makes it a bad idea either way and means it still is relevant.
It is unclear to YOU. It is not unclear to person doing the public praying or to God. If I pray publicly and my motivation is unclear to You, I am still going to pray. I know my real motivation and so does God.