How to wire 5 V proximity sensor Ender 3 V2?
That part seems dubious
Your part is labeled LJ18A3-8-Z/BX. That is a Z/BX type sensor of the LJ18A3-8 series - that first part dictates an M18 outer thread and thus dimensions and a triggering distance of 8mm. Z/BX indicates NPN NO, so a normally open sensor of the NPN type. However, that labeling indicates an inductive sensor with a required supply voltage of 6 to 36 V and a power draw of 10 mA between the supply and ground line and a digital output signal of 300 mA.
There is a variant in existence, that has a 5 V supply voltage, but its part number is different by 3 characters: LJ18A3-8-Z/BX-5V - the appended -5V is crucial to show it differs from the standard!
The Ender-3 Board
The Ender-3 board has a 24 V input from the power supply and runs its end-stops on 5 V logic. That would suffice to connect the output of a LJ18A3-8-Z/BX-5V sensor directly to a sensor pin.