For a mouse it has nothing to do with pixels - it usually refers to how many "units" the mouse claims to have moved when you slide it one inch across the table (these units were once called "Mickeys"). So in theory a "1200dpi" mouse would register a distance of "1" if you moved it 1/1200th of an inch.
In modern systems the amount of distance the cursor moves on the screen for each mouse unit varies depending on how quickly you move the mouse and how sensitive you've configured it to be.
For an image file (such as a JPG file, for example), the dpi setting in the image is a "suggestion" for how big the image should be displayed on the screen or printed on paper. But software is able to (and usually does) ignore that setting and display or print the image at a different size.
For a screen or for a printer, "100 dpi" really does mean, at least approximately, that there are 100 pixels or 100 printable resolution units per inch of paper or screen surface.