Once they've flowered that's it ... they won't keep flowering.
Yes, once flowering is finished the plant dies off above the ground. If you leave the tubers in the ground more plants will grow again next spring.
Tomatoes are short-lived perennials in their native habitat so you could probably keep one going for 2-3 years indoors but I'd guess that some real tlc as well as regular pruning would be needed or it could grow to 5 or more metres tall in a couple of years. Potatoes are closely related so the same may be true of them. They will die though, and likely in the winter as lack of light will do for them (both native to central/south America, so require lots of light.)