At an Oval Office meeting and during a stroll around the Martin Luther King Jr. Memorial, Mr. Obama and Mr. Modi emphasized what they had in common as democratic leaders who overcame personal obstacles, campaigned as outsiders and embraced technology as a vital tool in politics and governing.