Proximity sensor is of 3 wire, it must have a pair of wires for power supply and one for signal. To avoid confusion of 3 wires every time when you wire first connect the sensor with power supply. The obvious logic behind it that a sensor must be energized to develop unseen electric field in its surrounding. After all this not a miracle that sensor senses an object without touching it. So now when electric field is cut with the presence of an object it gives signal through signal wire.
Now you must be wondering what about 2-wire sensor where there is no separate wires for power supply. In 2-wire sensor, sensor gets power from the power supply through a residual current flow across the sensor. But also a input module must be chose in this case which must have enough leakage current to energize the circuits of the sensor.
As others said in their answer a proximity sensor are of PNP or NPN type. This information is very important to wire a sensor to a PLC input module.
Now how wiring differ considering PNP & NPN. In DC power supply, wiring can be source type or Sink Type. Source and Sink types defines the current flow from load to device with respect to power supply. PNP sensor is a source type device. So if you choose a input PLC module for that it should be sink type. If both are Sink type or both are source type interfacing would not happen. (Many PLC makers use different names too instead of Source and Sink)
In a source type device, power supply is always sourced from that device and it sinks in other connected device. The opposite of this same logic is applied to other connected device. That’s why that is a Sink type device.
For example in PNP sensor case, DC power supply positive terminal (24V+) will be connected to sensor positive side. The other terminal( signal wire) of sensor would be connected to Input point of module. So that sensor acts as source of power supply to input point of PLC module where current sinks in. To complete the circuit now connect input common point to negative terminal (24V -) of power supply. In this case whole circuit is completed and when sensor gets ON with the presence of any object it sends power supply to input module signal terminal. Now DC supply is given to a input point of module which energizes the coil inside input module and makes the input signal ON.
Opposite wiring happens in NPN type sensor. In this time PLC input module must be Source type as NPN sensor is a Sink type device. Here current passes from PLC input module to sensor. PLC input point acts as source and where current sinks in the sensor. If this basic rule is ignored I am afraid you will not get sensor signal in input PLC module.