Google search algorithm has progressed so that it look at latent semantic indexing, where it creates buckets of similar keywords that it will infer as having a shared meaning, particularly when used in conjunction with one another.
Whilst slightly outdated this article covers the way Google's synonym algorithm works and says that over 70% of searches are affected by the synonym algorithm. They explain that the way they decide whether to bold a synonym is:
Historically, we have bolded synonyms such as stemming variants —
like the word "picture" for a search with the word "pictures." Now,
we've extended this to words that our algorithms very confidently
think mean the same thing, even if they are spelled nothing like the
original term.
Google says that the same words may not always appear bolded because they analyse:
other words in your search and use many signals
They way that Google determines keywords that will fit in the various buckets is by:
Our systems analyze petabytes of web documents and historical search data to build an intricate understanding of what words can mean in different contexts
As I have said this article is slightly outdated, but seems to cover your question well. over the last 3 years this technology is likely to have been advanced significantly and the way they determine keywords is likely to have become significantly more accurate, however, the general principles will be similar