the sensor is physically screwed into the housing
the wiring is eiother stuck due to age . so gentle wiggling of the connector is required to pull it free
if you damaged the connector go to a scrap yard cut a full-length of wire and connector off and crimp or solder the connector to make a successful repair
a hairdryer may make the connector softer with heat to help removal
proper pain to get out they are
the sensor itself clips onto the inlet manifold too
best way to suss it is look at one in a srappy if you can so see how it comes out
if you can wait till next year i will take a photo of an engine i have out for you