Some people define asexuality as never experiencing sexual attraction towards other people. For example, gay people are attracted to the same sex, straight people are attracted to the opposite sex, but asexual people are attracted to neither/no one.
With that definition, asexual people can still have a libido, as in an ability and desire to have orgasms, to be sexually stimulated, etc. They may enjoy masturbating, but have no interest in partnered sex.
With this definition, however, I am not clear on what asexual people might think about/fantasize about when they are horny/masturbating.
The other definition of asexual I have heard is people who do not have any libido or sexual desires. Never get horny, never masturbate, etc. Maybe they can have orgasms, but the orgasm is not especially pleasurable or something they seek out.
I'm not asexual, but I have heard people who identify as asexual/ace define it either way, depending on the person.
Both "types" of asexuals may still engage in partnered sex for various reasons (such as they love someone sexual, they want to have a child, etc.).
Of course, asexuality is a spectrum and many people identify as gray-asexual, for both definitions, I assume.