For a number of guys, they don't get married before 40 either because they have no problem attracting female companionship and prefer having a series of long-term relationships, or because they preferred working on building up their careers or business.
Then they get to be 40, and decide it's time to get married and have some kids while they still have the energy to deal with them.
Your 40 year old female friends don't have to worry about what to do with such, though, because this segment is looking for a 30 year old woman who is still able to easily have multiple children before her fertility runs out.
For 40 year old single women, it's a different story. For the most part unless they look like Michelle Pfeiffer or Cate Blanchett, they're either going to need to settle for what they can get, or be resigned to living without male companionship.
They might settle for a younger man, if all the young women are taken by older guys.