I have a 3rd party module installed in my magento. I want to do some modification. I should modify the module directly or write another module to override it? Please advise
You should never directly modify any 3rd party modules.
Depending on what you want to modify, you should create your own module that depends on that 3rd party module and inside your own module make the modifications you want.
For example, if you want to modify the output of a method you should use plugins, or if you want to modify a template you should copy the template from the module into your own and do the modifications there.
I think, creating your own repository for the module and do the modifications is the way to go. I am handling some modules like this - especially some modules, that are not available over composer.
If the module is an open-source project, you can do a fork and work with that. And if you are adding some features/functionality, you may can contribute to the project. Some commercial products are also happy to get some help with implementing new stuff.
I dont like "overwriting" files. It is made for breaking stuff in the future. Fork or copy the module and do your thing...