What Are These Runway Lights For?
As for what they are you can find that in the answer to the question here. In terms of how they work its an extension of the basic runway lighting system. There is a nice video discussing the various types here but effectively they help guide the pilot to the runway by providing them with an extended way to infer where the centerline is (beyond the runway its self) when making a low visibility approach. The system may also include a decision bar which helps a pilot by having a visual marker at a fixed distance from the threshold. Keep in mind that threshold lights lights count as runway in sight so the extended centerline can help a pilot lineup when they can not see the full length of the runway. 

The colors will vary based on what the airport in question is equipped with but green is the runway threshold. Red is typically an area in front of the runway, it could be a displaced threshold or it could be an area off the runway all together. However these lights will appear on both ends of the runway and will be visible when approaching from that direction. 

It should be noted that while certain lights are required for certain types of operations, lighting is not explicitly required by the FAA and there are plenty of unlit airports as well as a wide variety of lighting situations out there. The field I fly out of has REIL and 5 lights on each side of the runway which is far less than a class B airport would have but may be far more than your back country grass strip has.