I am trying to understand why some European governments won't close their patent office if the EPO can replace their patent offices since any company can obtain a patent through the EPO.
It's not that simple, because technically the EPO doesn't provide a single European patent but only a unified procedure for obtaining a "bundle of patents" for the different participating countries. From Wikipedia:
The European Patent Office (EPO) grants European patents covering the Contracting States to the European Patent Convention and several other states that have concluded extension and validation agreements with the EPO. The EPO provides a single patent grant procedure, but not a single patent from the point of view of enforcement. Hence a patent granted by the EPO is not a single or unitary European Union patent or uniformly recognised Europe-wide patent, but a bundle of national patents. Patents granted by the EPO can, however, be challenged centrally at the EPO via opposition proceedings.
But a real European patent is "in advanced stage of adoption". Apparently the crucial obstacle is translation (or lack thereof). The goal is to simplify the process and reduce the cost for the applicant:
By not requiring translations into a language of each contracting state, and by requiring the payment of only a single renewal fee for the group of contracting states, the unitary patent aims to be cheaper than European patents. Instead, unitary patents will be accepted in English, French, or German with no further translation required after grant
However Spain and Italy contested:
On 30 May 2011, Italy and Spain challenged the council's authorisation of the use of enhanced co-operation to introduce the trilingual (English, French, German) system for the unitary patent, which they viewed as discriminatory to their languages, with the CJEU on the grounds that it did not comply with the EU treaties.
The court handed down its decisions on 5 May 2015 as ECLI:EU:C:2015:298 and ECLI:EU:C:2015:299 fully dismissing the Spanish claims. Following a request by the government of Italy, it became a participant of the unitary patent regulations in September 2015.
To date most EU member states participate in the unitary patent system (except Spain and Croatia), but many countries haven't ratified the agreement yet.