Asexuality doesn’t stop you from having sex. Having sex doesn’t disqualify you from being asexual.
You can identify with any sexual orientation and have sex or don’t have sex with whomever you want, as long as it’s legal and consensual.
There are many factors why someone has sex. Sexual attraction is only one of them. It’s an important one, because it indicates what gender(s) your sexual interest is directed at. But it’s not the only one and probably not THE most important one. I’ll list a few examples.
1. You can have sex to find out whether you like it or not.
2. You can have sex, because you have a high sex drive.
3. You can have sex, because you enjoy the feeling.
4. You can have sex to show your partner affection.
5. You can have sex to please your partner.
6. You can have sex, because it’s expected of you and you don’t know better.
7. You can have sex to make a baby.
There are more reasons why people in general, including asexual people, have sex other than feeling sexual attraction towards someone. At the end of the day, it’s up to the individual whether they have sex or not and for what reason.
See also You can’t know till you’ve tried it