First, let’s go over how pregnancy happens. When someone with a penis ejaculates into a vagina, their sperm cells swim up the fallopian tubes, looking for an egg. (This can happen without ejaculation, thanks to pre-cum, too). If a sperm cell meets an egg, that egg becomes fertilized. If the fertilized egg implants in the uterus, pregnancy officially begins.
Now, let’s go over how anal sex works. Someone's penis, strap-on dildo, sex toy, fist, or fingers enters someone else’s anus and moves around, helped along by lube (don’t forget the lube!). Pregnancy doesn't happen during anal sex because the anus isn't connected to the vagina or any other reproductive organs. People without vaginas can't get pregnant — while "m-preg" is a popular fanfiction category, it doesn't work that way in real life: trans men can get pregnant, but cis men cannot.
There is one way in which anal sex could result in pregnancy: if semen enters the vagina after ejaculation. According to Planned Parenthood, “Since your anus isn’t connected to your reproductive organs, anal sex can’t directly cause pregnancy. But it’s still possible for semen to get into the vagina during anal sex — if the guy ejaculates into or near the anus, and the semen leaks from there down onto the vulva. Fingers and hands could make this more likely, too, by moving semen towards the vulva.”
That means that if someone has anal sex and then ejaculates into the anus or somewhere else near the vagina, sperm could theoretically, accidentally, enter the vagina and cause a pregnancy. If someone ejaculates after anal sex, touches the semen, and then fingers their partner, that could theoretically result in a pregnancy, too. But if semen doesn’t enter the vagina, there’s no chance of pregnancy happening.
If you’re worried about this rare situation, there’s an easy solution: use a condom. Because you can transmit STIs during anal sex, it’s a good idea to use a condom, anyway.