Okay, I assume that you have connected the two resistors and the sensor to the Rpi?
When the induction sensor doesn't see metal, the output of that sensor will be noting. Because it has a PNP output, (but you can read is at 0V). In this case R2 will ensure that the voltage at the Rpi is 0V and you read a digital "0".
When the sensor sees something, the PNP transistor goes into condition, and the input voltage of the sensor is present at the output. The 12V that you measured before, the two resistors will riduse the voltage to a save input level for the Rpi. And it will read that as an digital "1" .
I hope this makes some sense to you
And to make a little bit more confusing, the Rpi doesn't have an analog input. Every signal <=0.9V will be seen as a digital "0" and everything above 1.6V is a digital "1". Between 0.9V and 1.6V could be anything and you don't want to operate here ever.