Why can't we always create a vaccine against a virus when an ELISA test to detect it is possible?
I found the question quite interesting and will to provide a concept and a speculation although I could not answer the question to my own satisfaction (edits to this regard are welcome)

Currently (2020), the advanced form of ELISA tests for HIV are designed to simultaneously detect both the HIV P24 antigen (produced by the virus) and anti-HIV igG and igM antibodies (produced by the body in response to the virus). Refs (CDC: What kinds of tests are available, and how do they work?)(HIV Diagnostic Testing: 30 Years of Evolution)

While it is easy to detect known viral antigens like the p24 capsid protein in a diagnostic, it is not straightforward to use the same antigen as a vaccine and expect the host to mount an immune response that neutralizes the viral infection, although attempts have been ongoing. Possible scenarios could be that the binding strength of the antibody to P24 might be good enough for detection, but not enough for immunity or that recognizing and binding to P24 does not inhibit the infection. Coming to the evolution/mutation question, since both the p24 antigen and a few antibodies are being detected, it is unlikely the virus would mutate so as to evade the ELISA for all the targets.

The first point in Charlie's answer might be getting at this but it did not come through clearly.