As Todd Gardiner says, they don't -- but the cameras have to produce a regular image file, and many of these file formats have a field for the DPI. So the cameras just plug in a default value like 72, 180 or 300 for the files they produce. Adobe Camera RAW arbitrarily assigns a DPI value for RAW files it processes -- you can change it.
Historically (the 80s and 90s) DPI was very important when you created a digital image by scanning something physical, like a slide or a print. A higher DPI meant a higher resolution image -- there was a huge difference in the amount of detail and information in a 300 DPI scan versus a 72 DPI scan (the "rule of thumb" DPI of monitors was 72, and a laser printer was 300 in case you were wondering where those values come from)
Thus DPI became a "shorthand" for image quality -- which is somewhat misleading, but it was such a useful shorthand that it stuck. Editors and pre-press production people would ask for a "high resolution file", meaning a high DPI value. They knew from bitter experience that if they got a 72 DPI scan (or other low resolution), the image would be useless for printing.
Fast forward to digital image capture, where none of this makes any sense because there is no scan of a physical intermediary like a slide any more. There's just what comes off the camera sensor, and DPI has no meaning in this context. The amount of useful data in a digital photo straight out of the camera is determined by the dimensions and pixel arrangement of the sensor. You can set the DPI value of the resulting image file to be 72 or 3,000 and the image still has the same amount of information in it -- DPI doesn't matter.
The idea that the DPI value of the file determines image quality persists, however, long after it has outlived its usefulness for digitally captured images. I sell stock photos and still get requests for "high resolution files" from book and magazine production people. I send them the largest file I have without upsizing (typically matching the original pixel dimensions of the camera sensor), with the DPI value set to 300. I have a Photoshop Action that does this for me. The power of DPI is so strong that some people still get upset if DPI isn't >= 300, even though I could set DPI to 1 and it would still be the same image data containing the same amount of information.