A lone gunman, Micah Xavier Johnson, fired on police officers in Dallas during a peaceful protest against police brutality - killing five police officers and injuring seven more as well as two civilians.
"We can not let the actions of a few define all of us", he said.
Obama, while saying there was a "persistent problem of African-Americans and Latinos being treated differently in our criminal justice system", stressed he did not believe the country was descending into the polarization seen in the sometimes violent civil rights struggles of the 1960s.
The president, speaking on Saturday at the North Atlantic Treaty Organisation summit here, suggested that the licensed gun in the auto of Philando Castile, who was shot by police in Minnesota during a routine traffic stop, had contributed to the tragedy there.
"If you over-classify, then all the advantages of this new information suddenly go away because it's taking too long to process", the president said.
The president cut short his stay in Warsaw for the North Atlantic Treaty Organisation summit to return to Washington on Sunday after visiting Spain.
Thousands of protesters marched in U.S. cities late Friday, with many remembering the slain officers, but anger remains over the deaths of Alton Sterling in Louisiana and Philando Castile in Minnesota, two African-American men killed by police.
He also said that the black U.S. military veteran alleged to have killed five policemen in Dallas is not representative of African-Americans.
Obama praised the professionalism of the Dallas police force during the attack, and emphasized that the shootings shouldn't be seen as representing a wider political statement.
Obama spoke about the deadly shooting of police officers early Friday.
During his address, President Obama was also asked about the ongoing problem of mass shootings in the USA and the possibility of tighter gun control legislation.
Since Thursday's shooting left five police officers dead, several blocks of downtown Dallas have been blockaded, with public access to a large part of the area denied.
"When we start suggesting that somehow there's this enormous polarisation and we're back to the situation in the 60s and - that's just not true", Obama said.
"How the negotiations work, I think is going to be up to the parties involved", the president said Saturday.
"There is sorrow, there is anger, there is confusion about next steps, but there is unity in recognizing that this is not how we want our communities to operate".
"The individual who carried out the attacks in Dallas, he's no more representative of African-Americans than the shooter in Charleston was representative of white Americans", Obama said in reference to Dylann Roof who gunned down nine black churchgoers past year.
The U.S.is helping to organize an global conference on migration in September, with Obama noting that "a few countries shouldn't be shouldering the burden for 60 million refugees". President Obama is also expected to return to the United States one day earlier than planned. "But we can make it harder for them to do so".
Police often have a hard time in communities where guns are more plentiful and have very little margin for error when making decisions, he said.
Speaking of the legacy of global institutions such as the E.U., North Atlantic Treaty Organisation and the United Nations, he said, "We should be proud of that and preserve it".