TOKYO — Japan and South Korea finalized a sweeping free-trade agreement Thursday that removes tariffs on semiconductors, automobiles and green-technology goods between the two economies. The pact also creates joint research frameworks in battery storage and shipbuilding. It lands as both governments seek to deepen ties amid shifting alliances across the Asia-Pacific region.