If your friend disclosed to the immigration officer during their visa interview that they plan to give birth in the U.S., and their visa was granted, that is perfectly fine. Likewise, if they inform CBP upon arrival and are still allowed entry, there is no issue.
However, I doubt your friend has done either of these. While it is not illegal to give birth in the U.S., and current law grants the child U.S. citizenship, your friend should not assume this will provide any immigration benefits for the parents. According to a Georgetown study in 2013, over 153,000 children have had at least one parent deported. (I am sure the numbers are much higher now) Having a U.S. citizen child does not automatically grant legal status to the parents.
Additionally, the cost of childbirth in the U.S. can be extremely high, and your friend is taking a significant financial and legal risk. Lying to immigration officers—whether during the visa interview or at the CBP checkpoint can lead to denial of entry, visa revocation, and even future bans from the U.S.
Lastly, there is ongoing political debate about ending birthright citizenship. While it is unclear how such a policy change would be implemented, it is a possibility under this administration. Your friend should carefully consider all these factors before proceeding.
Also, myself being an immigrant from Pakistan and knowing the Pakistani community here always run in these scenarios and I can assure you none of the people who did this will have anything positive to say about it (because most of them chose to become illegal themselves after the child birth).