In Photoshop, I set the dimensions of a tiff image to 4x4 cm. When I insert this image into a frame in InDesign, and then fit the frame to content, the dimensions of the frame become 3.9963 x 3.9963. The same thing happens when I do it in QuarkXPress. Why does this happen and how can I fix this?
It's a problem made from photoshop relying on pixels and InDesign and Quark on, well, printable dimensions.
Just go to photoshop and change CM to MM and it will show you 39,96 mm.
Usually the difference is so small we don't look at it. Problem arise when you have additional borders that add "points" and then you use the outcome to place it in set dimension (like an ad in the newspaper).
For me it was always better to have more than less. So I upped the pixels dimensions. In your case in 300 dpi you will have 472. So I would change that to 473.
If you have a need to place many such image close to each other and have finite space (like a page) always align to the picture to the centre of image box so the excess will be hidden.
It's only a tiny rounding error caused by the fact that raster images are made of pixels - in other words: because you can't have fractions of a pixel, only whole pixels.
You probably don't need to worry about it. In all my years doing graphic design, it has never once caused me a problem. The difference is only a few hundredths of a millimetre. For most work that shouldn't matter.