Any sale or purchase of, and any consolidation by sale, or otherwise, or any lease, or agreement to sell, consolidate with or lease, the whole or any part of any railroad, or the branch lines of any company, whether organized or located within or without this state, with the franchises appertaining thereto, to, from or with any railroad company organized under the laws of the United States or of this state or any other state or territory, or any consolidation between such companies, executed prior to March 18, 1909 by the proper officers of the respective companies, parties to such sale, lease or consolidation or contract, is hereby legalized and made in all respects valid and binding from the date of its execution: PROVIDED, That the provisions of this section shall not apply when the railroads or transportation corporations involved are competing lines.