Even if the analogy doesn't quite apply, a simplified model might help.
If you use a DBMS such as SQLite, you can see the database as a black box from the application's point of view.
The application is basically not responsible for data storage, optimisation, indexing or any other administrative tasks relating to the data.
You can retrieve data from this black box using the SELECT commands. The DBMS is usually also responsible for sorting the required data. You get the data the way you want it. That's it.
However, you can not only query a single table but also design the query in such a way that several tables are combined. For example, you can get the name, address and telephone number of several people in one query.
For example, the user enters a location in the search window and receives a list of people with address and telephone number.
You can query many things at the same time, but you can only write one table at a time.
So there is no active index that can be set, only a desired sorting that you want to have in the query result. The DBMS decides which index (or several or even a full table scan) to use with the help of its query optimiser. The application has no influence on this.
You can create intelligent indices in the DBMS, but the optimiser decides on their use.
You no longer have anything to do with all the indices and switching between them. You only request the desired sorting.
SELECT <fieldlist>
FROM <tablename>
ORDER BY <fieldname1,fieldname2,fieldnameN>
If you want a different sorting, request a new result set from the DBMS with a new SELECT.
This is normally so fast that the new query is not a problem. I practically always do it this way.