It's to do with how the machine stores numbers and processes mathematical stuff internally. One of the more common ways in which computers store numbers is called "floating point" representation. This is based on binary, encoding numbers as a sequence of ones and zeroes.
Similarly to how the everyday base-10 (decimal) system we use makes it impossible to express 1/3 precisely (e.g. 0.333333333333...), the floating point system generally used by computers has difficulty in expressing certain numbers precisely. This is often referred to as "floating point inaccuracy".
There are other ways in which to store numbers on a computer which wouldn't have any problem with the examples you posted, but there is some trade-off in the amount of memory required to store the numbers and the efficiency with which mathematical calculations can be processed.