Was Tracy Mills his intended target from the beginning?
Highly unlikely.
We know the killer has been working on this for months. We don't know whether he changed his plan after meeting Mills. This leaves us 2 options:
He had targets for all 7 sins, but was forced to change them due to Mills
He had decided to use the cops assigned to his case (with some luck, they could be triggered into the final sins)
In the first scenario, Tracy wasn't part of the plan, as wasn't Mills. He just had his 7 targets, and was going to execute them. When his hand was forced, he decided to use Mills and his wife. In the second scenario, he has to wait for Mills to be assigned, and again, Tracy is an unknown factor, as the cops assigned might not have had wives, and instead children or something.
Did John Doe decide to kill Tracy only after Detective Mills and Somerset discovered his residence?
Essentially, yes. Although we don't know if he had decided to use the cop and someone he loved from the beginning, or just some specific targets for those sins. But as they forced his hand, all we see is his final plan.
This answer presents the same theory.