The manufacturers place very conservative tunes on the vehicles from the factory. They do this for two reasons. First of all for longevity. By placing the conservative tune on there, the engine will last longer. Secondly, they do it to ensure they meet things like mileage and emissions goals.
It's very easy for engines with turbo chargers on them to create more horsepower. All you have to do is to allow the turbo to build more boost and add more fuel to cover the increased volumetric efficiency.
It's also easy to have more horsepower in diesel engines, just by allowing them to spin higher (increase the redline on the engine).
However you do it, the remap is pretty simple, but should really be done by someone who knows what they are doing. It's just a file which gets put into the engine control unit (ECU) usually via the data link connector (DLC). It takes special software, which is has specific protocols for specific vehicles.
Does it hurt the engine? Only if you abuse it. If you never use the increased power, it really doesn't matter. Is that realistic? Not at all. The reason you put it on there is to get more out of the engine. Most engines can handle the relatively small boost in horsepower, as can the powertrain. When you have to change out parts to get things to make the power you are looking for (such as larger injectors to flow the needed fuel, or a larger turbo to produce enough boost), then you need to start worrying about the longevity of the engine and drivetrain. We were discussing this on chat earlier. The basic consensus is, the candle which is burnt at both ends burns twice as bright, burns only half as long. What this means is, the harder you push the engine, the faster you can expect it to deteriorate. There is no magic formula for this, but it is true nonetheless.