Poland has signed a landmark deal to build the first EU gas pipeline to the isolated Baltic countries and lessen their reliance on Russia.