If I think I understand your question correctly, yes 4 days is plenty of time. Most people do the KM104 trek with a tour of Machu Picchu and back to Cusco in just two days.
The only way to do the KM 104 trek is by hiking. You get off the train at the KM 104 "stop" and hike the final 5 or 6 hours of the full Inca Trail hike, which leads to Machu Picchu. Once you reach Machu Picchu you don't enter the ruins, you take a bus down to Aguas Calientes to overnight in a hotel. Then in the morning you take a tour of Machu Picchu, before returning to Aguas Calientes for the train back to Cusco. This is the only way to get to and from Machu Picchu on the KM 104 trek.
I hope that helps!