How is the definition position_endstop applied?

With position_endstop and position_max you are talking about the physical limits of your printer. Where it finds it endstops and how far from it an axis can safely travel.

The general logic thus depends on the mechanical setup of your printer. Bed-slingers (e.g. Ender 3) often have their X, Y endstops at 0 and you tune the endstop position with a screw so that your nozzle is exactly at the bed’s origin. With position_max you tell the axis how far it then can mechanically safely travel, e.g.

position_endstop: 0
position_max: 235

This can go even outside of your bed. This is useful, especially when you use a bltouch / probe. Due to its offset from the nozzle, the nozzle may already be beyond the bed but the probe still is on it (remember: valid printing area is set in slicer).

Negative values again depend on the physical position of the endstop and are also needed to maximize a probing area or account for “strange” endstop positions. It means the head can move even past the endstop for the given distance, e.g.

position_min: -5
position_endstop: 0
position_max: 235

Klipper verifies that any move are between position_min (Default 0) and position_max (the physical limit of your axes)

Edit for more clarity