Defunct refers to the company making a product and obsolete refers to the product itself.
For example, consider Netscape Navigator:
Netscape Navigator was a proprietary web browser, and the original browser of the Netscape line, from versions 1 to 4.08, and 9.x. It was the flagship product of the Netscape Communications Corp and was the dominant web browser in terms of usage share in the 1990s, but by 2002 its use had almost disappeared. source
Netscape Communications Corp is defunct as the company is no longer in business. It was bought by AOL. In contrast, its Netscape Navigator is obsolete. This browser cannot handle many modern HTML conventions.
The OP cited an example of a defunct rail line. Lexico.com
the now defunct Somerset & Dorset railway line
This means that the line is no longer being used (and perhaps stopped carrying passengers only a week ago). It is not functioning at the moment, but could be in the future. That defunct railway line could be dusted off and recommissioned next week. While not broken, it is not being used in its original capacity.
If the manufacturer of the train were out of business, then it would be defunct, as well.
The engines on that rail line could be obsolete steam locomotives. But you would not call the engines defunct.