Connect 2 PC together with an LAN Cable

a question from a beginner. I don't understand why we have to manage Ip (like put a static Ip address) in this process. I tought we were in layer2(mac,lan,ehernet) here and not in the layer3(Ip) of Osi model. Could someone explain me something? Thank you all