There is that third variable, but there are also studies that control for geography and even study a stable population of depressed patients.
There's also a lot of theory to back up the idea that guns increase suicide rates.
First, if people have to take time to prep for suicide, they have time to think and sometimes change their minds. With a gun, the time between thought and action is so small, they don't have this chance.
Second, guns have a much higher success rate than most other methods. This is why women attempt suicide at higher rates, but succeed far less often -- they usually don't use guns.
There are studies that look at a stable population, and they find that the same person is much more likely to succeed at suicide after they become a gun owner.