the mistake is to think of dpi as being a unit of size - it is not, it is a unit of density

the size of an image is how many pixels it is hight and width.

dpi defines how those pixels are spread out on the device, specifically a printer; and as you say.. monitors are different because you cannot change the distance between pixels on the fly, for a given screen resolution that spacing is fixed