A 'do not attempt cpr' order basically means if someone's heart stops beating, so, if they die, people will not do chest compressions or put a breathing tube down their throat or put needles into their veins or their bone to give them drugs.
It doesn't mean they won't be treated if they're ill, it won't mean they will be left to suffer pain or discomfort, it won't mean they will be denied food or drink. It just means that when they reach the end of their life they will be allowed to die.
CPR is horrible, brutal, undignified and rarely successful. It's horrific to do it to someone when you know it's the wrong thing to do. If someone is clearly approaching the end of their life - if they have terminal cancer for example, it's clear to the medical team looking after them that they will die at some point and that trying to bring them back after they've died is the wrong thing to do. Sometimes talking through this is distressing for patients and their families. Sometimes the conversation is unnecessary - if someone is going to a hospice to die or is having intensive care withdrawn at the end of their life because treatment isn't working, there is no need to have the discussion that when the heart stops beating we won't try to start it again.
Doctors are not wandering round the wards secretly writing dnacpr forms in random peoples notes just cause they don't want to look after them any more. Generally it will be discussed with the patient and their family. But sometimes it's clear a patient is reaching the end of their life and, although this will be discussed with the family, the fact that once they die we will accept that they have died doesn't need to be spelled out. The form still needs to be in the notes though so when the patient passes away the team caring for them know what they do and don't need to do.