If anyone can mine how does inflation not occur? If you can mine money whenever you want how does the price of every bitcoin not diminish?
The answer to your question can be found on the Bitcoin wiki.

It's true that everyone can mine, but the amount of coins that are up to be mined by miners is controlled by the Bitcoin protocol.

The difficulty of mining a "block" is adjusted automatically (every 2016 blocks or ~ 2 weeks). The adjustment is made by all miners using a transparent calculation. The adjustment aims to retain a rate of approximately 1 block mined every 10 minutes.

Additionally, every ~4 years (or 210000 blocks), the reward for finding a block is halved.

Taking this two things in account, the reward for mining a block will become zero after 6930000 blocks or ~136 years. (It becomes zero because the precision in which bitcoins can me measured is too low.)

You may think that people will stop mining when the reward becomes too low, but you have to keep in mind that miners also get the transaction fees from the transactions they verify in their blocks. Currently the accumulated fee is only a fraction of the total reward, but as the reward decreases (and Bitcoin raises in value), these fees will (hopefully) become a sufficient incentive to mine.