Don’t be a hypocrite! The Pharisee’s, prayed in public, to please man. It was all about them. It’s not a sin to never pray in public, but here, Jesus is saying, separate yourselves from the distractions, that you may focus on on God.

But you, when you pray, go into your inner room, close your door and pray to your Father who is in secret, and your Father who sees what is done in secret will reward you.
MATTHEW 6:6 NASB
https://bible.com/verse-of-the-day/mat.6.6/30013