Elevator is a closed and narrow space. Sharing one elevator with a virus carrier, you may get infected through his/her droplets spread by coughs, sneezes, and speeches.
If droplets fall on buttons or walls, the virus can be spread to other persons by contact. They may get infected by touching their mouth, nose or eyes before washing their hands.
But don't worry. just remember the following three sentences to prevent COVID-19:
Wear a mask when taking an elevator
Don't touch your face with your hands.
Wash your hands when you get home.