Montevideo , founded by the Spanish in 1726 as a military stronghold , soon took advantage of its natural harbor to become an important commercial center .