What you're missing, in short, is filtration and delivery.
Most hearing aids don't deliver sound directly to the damaged ear canal, but also utilise other sound delivery mechanisms. Like induction. This can help prevent damaging the ear internals further.
They also rarely deliver a 1:1 version of the sound in the world around us, because a damaged ear drum already distorts the sound it receives. There is no need to make it harder for the brain to filter out background noise. These filters can be simple - a dial switch on the device, or they can be complex - adaptive filtering based on the current environment. The filter complexity and effectiveness is usually reflected in the price, but as software gets better and hardware more powerful things are slowly shifting towards a better median.
The higher-end hearing aids can also be tweaked by the specialists involved to avoid frequencies that can further damage the ear, but that tends to be on a case-by-case basis and is difficult to tune correctly for an individual.
But you're right - if the hearing aid isn't tuned correctly, or the individual regularly just turns it all the way up, it can lead to further loss. Which is why many doctors have regular appointments to check the device is in a safe range.
The bad habit of the user, turning the device up, can usually be prevented by better sound filtration. They're turning it up because they can't hear something they're trying to focus on, making it easier to focus at lower volumes can curb the habit.