If we are taking the train from Strasbourg to Colmar and back for entire day, is it possible to taxi to and from Eguisheim for a few hours from Colmar?
If you look at Google maps it is only 4 miles or 7Km away. If you can't figure out how to do this by the bus or you are not into renting a bike, in this situation the best practice is to arrange to have the cab driver pick you up at the same place where s/he dropped you off at a certain time when you are ready to come back.
Bus service is limited: https://www.l-k.fr/wp-content/uploads/2019/01/68r030-2023.pdf
I don't recall if there is an actual taxi stand outside the Colmar station, in which case you'll have to arrange for a taxi yourself.
The bus service is timed to meet the trains to and from Strasbourg, so it's actually very convenient, except on Sundays when it is indeed non-existent, and it is limited on Saturday afternoons.
I just did this with family this summer.
At Colmar, we were able to pick up a taxi right outside the train station that took us to Eguisheim. I asked the driver if he could pick us up at a fixed time later, but he told me that I'd have to call the central dispatching facility or have someone call it. (I speak French so I am certain this was not a language misunderstanding).
In Eguisheim I also paid a visit to the small tourism office, which also told me that they could call a taxi for me to go back to Colmar. The only slight wrinkle is that the tourism office closes for lunch, so you have to take that into account.
We ended up taking an Uber back from Eguisheim to Colmar, but I wouldn't depend on that as your Plan A. Uber availability is (unsurprisingly) nothing like that in major cities, so I'd only have that as a Plan B.