Why do some aircraft stay in airports for a long time?
There are many reasons. At least one is that the airline may not need that airframe type until later that day (the next flight that requires said airframe). Airlines don't just fly any plane they have on any route they have, this would be terribly inefficient and involve using an airplane that is not needed for a given mission. Take any major airline for example that fly large planes to lots of destination in Europe. Lets say that they have a 777 Arrive at EWR from Paris. The next long haul flight that airline has out of EWR is that evening to Dublin. But though out the day the carrier has 2 commuter flights down to Charlottesville VA totaling about 100 passengers between the two flights. They are not going to use a 777 to move 100 people and some light bags, so the plane sits until its needed again. 

All planes (even non commercial) are built for a given "mission" much like you would not buy a Ferrari if you wanted a car that was good on gas.