Posts on Mastodon, also known as Toots, have a privacy setting.
You can change a toot's privacy while writing it by clicking on the privacy icon. Depending on what the setting is, and depending on how you access Mastodon, privacy will look like a globe 🌐 🌎 or a lock 🔒 or a group 👥 or an envelope ✉️ or an @ sign.
Pick the privacy you want before you publish a toot, as you can't alter it later (unless you delete the toot).
You can also choose a default privacy setting in your account settings. New toots will automatically use the default privacy unless you change it.
On the website, go to Preferences > Other > Posting Privacy, choose the default privacy you want and press "Save Changes".
On the official app, go to ⚙️ Settings > The Boring Zone > Account Settings and then log into the website.