The two measurements used to determine tyre size is the diameter of the rim/tyre and the width of the tyre. 

The diameter corresponds to the installed wheel size, for example the Imperial standard: 20, 24,26, 27.5, 28 or 29 inches. They can also be written in the French standard, for example: 700c = 28 inches or 650b = 27.5. There is also the ERTRO (European Tyre and Rim Technical Organization) standard which uses the rim circumference/ tyre inner circumference, for example: 28 inch = 700c = 622 mm ERTRO, 26 inches = 559 mm ERTRO, 27.5inches = 650b = 584 mm ERTRO.  

Selecting the correct width is dependent on the width of your rim and the space available between your fork, the seatstays and chainstays. Going a few mm over or under the tyre size your bike came with is possible. The two reasons you would do this is for less rolling resistance by going down a few mm or going up a few for more grip. The design of the tyre may also determine if they fit in the frame or fork, for example tyres with big lugs may contact the frame.

If you are changing wheelsets or looking to upgrade your wheels, the internal rim diameter also will determine the tyre size you need on the rim. For example, when you have a 19 mm wide internal width on a rim fitting a 2.5 inch (64 mm) wide tyre would not allow the tyre to take the shape it needs to run properly and the same works in reverse when you have rims too wide for a tyre. There are charts to find recommended rim and tyre width combinations on most tyre manufacturer sites.