A speech by the Russian president set out military advances and warnings to the West three weeks before the country’s presidential election.