There are two predominant visa types, single intent and dual intent. Most visas are single intent, meaning that an individual who enters the United States is presumed to leave upon the conclusion of the visa status. Some visas, notably H-1B, L-1B, and L-1A, are dual intent, which means that individual can pursue permanent residence while in that status.
An individual can apply for a green card while in the country in any visa status. However, once an individual in a single intent status applies for the opportunity to be a permanent resident, if that person leaves the country before the green card is granted, he/she may not be let back into the country.
Once the individual files an I-485 for the physical green card the person can also apply for advance parole, to be allowed to re-enter the US before the green card is granted.