...Should I start by figuring out the harmonies? How about the form?
Yes to both.
But, you would also look at rhythm, melody, metrical treatment, scale degrees, counterpoint and texture, accompaniment styles, instrumental genres, and on and on...
But to do this well goes beyond a step by step guide. If it were that easy, then all the great master composer works would amount to mere formula. At the very least you can't lump "composer" together. You wouldn't have one step by step method that would work for two composers like, for example, Handel and Bartok, or Bach and Satie.
You should also ask yourself how authentically you are trying to emulate a given composer. You can probably convince friends and family that something is "in the style of Mozart" by playing cadential harmonies with Alberti bass accompaniment and simple even rhythms... but you probably won't convince someone that way if they can tell the difference between Haydn and Mozart.
...I ask this because I know that writing in the style of a given composer is a common exercise...
I think it's more common to use a piece by a master composer as a template to practice composition, but that isn't necessarily an exercise in mimicking that composer's style. I think the important thing is to be aware of the difference.
For example, you could take a Haydn sonata, make a harmonic reduction, note where the cadences and structural sections begin and end, then fill in that skeleton with your own rhythms and melodic contours. The harmonic skeleton gives you a sort of "safe" formal structure to cover a certain amount of space - sort like the lines of a paint by number picture - your add rhythm and melody to make it unique. You started with Haydn, but the end result won't necessarily sound like Haydn.