If you use a public visibility setting on a post, it will be visible to everyone, even people who aren’t Fediverse members. This means the post may be indexed by search engines.
The surest and safest way to prevent a post ending up on a search engine’s index is to use a non-public visibility setting. Followers-only and Mentioned settings cannot be seen by search engines, so they will not be indexed.
Mastodon has an option to request that search engines don’t index your public posts: go to Preferences > Other > Opt out of search engine indexing, tick the box and click Save changes. However, it’s up to a search engine to decide if it wants to honour this request, and it may choose not to. If you want a post to remain off search engines, it’s much safer to use a non-public setting.