After giving birth vaginally, how long does it generally take for the vagina to return to the state it was before?
During birth, the pelvic floor is stretched significantly, and the stretch is probable to never get back to the way it was exactly before.
The NHS states it takes a few days for the swelling and openness [...] to reduce [...] after your baby is born. An interview on the independent says that it should at most take 6 weeks for the vagina to get roughly back to before:
The vagina is an extremely forgiving part of the body, it can be very swollen and can look quite distressing to some people but after six weeks when the healing has happened it can go back to looking quite normal. If you have had a normal delivery it is common, for some degree, to have bruising on the vagina but this and the swelling should all go within six weeks.
Source: The Independent: What Happens to the Vagina after Childbirth? Obstetrician reveals it all, 2017.
It is strongly recommended to visit a doctor 6 weeks after the birth (other sources say prior to 12 weeks) so they'll check the vagina, cervix, and uterus. If one feels pain, if the vagina is bleeding more than usual, one should schedule an appointment before.
For further reading, this is a good study regarding postpartum care:
Romano M, Cacciatore A, Giordano R, La Rosa B (April 2010). "Postpartum period: three distinct but continuous phases". Journal of Prenatal Medicine.