Can I be asexual if I get erections?
You can. Erections are related to arousal, not sexual attraction.
In fact, it's common for men to get erections even when not aroused, which can happen as a result of tactile stimulation. Some aspects of arousal, such as erections, can be entirely unconscious and do not necessarily imply a desire for sex – which can be particularly confusing and shame-inducing for male victims of rape. Erections can also happen for no reason whatever, and it's normal for men to occasionally get erections during sleep (which is called nocturnal penile tumescence).
It is even possible to experience erections in response to non-sexual arousal. For example, you might get erections as an involuntary response to a combination of non-sexual touch and strong feelings of friendship.
Ultimately the take away is that erections are a physical response in your body – but to know if you're asexual or not you need to ask what your desires are, not what your body does. If you don't what to have sex with people you're asexual. Erections, just like other aspects of the human body, can be confusing or upsetting, and it might take time to come to terms with them. That's ok. It's normal and doesn't make you broken or less complete in any way.