The attacks on Monday and Tuesday took place in the villages of Debiro Hawul and Debiro Bi in Borno state.
Residents say the militants drove into the towns and began shooting, looting and burning houses.
In a separate attack, a young female suicide bomber reportedly killed at least 10 people in the neighbouring state of Yobe.
A witness said the girl, who detonated explosives in the town of Gujba on Tuesday, was about 12 years old.
The Islamist group has not commented on the attack but it is known for carrying out such bombings.
Earlier this year, the Nigerian army seized Gujba from the militant group Boko Haram.
Some 18,000 people have been killed in Nigeria since the group began a campaign of violence in 2009.
One resident who fled Debiro Hawul said that the attack had taken the village by surprise.
"It never occurred to us we would be the next target," Umaru Markus told the AFP news agency.
"The gunmen slaughtered 22 people who were not fast enough in fleeing and went about looting homes, grains silos and drug stores," he added.
Tuesday's attack in Gujba happened at about 11:00 local time (10:00 GMT).
"It was a suicide attack by a girl of around 12 years," said witness Hussaini Aisami.
"She went into the market and headed straight to the grain section. She detonated her explosives in the middle of traders and customers."
That attack came a day after two female suicide bombers attacked the north-eastern city of Maiduguri, killing at least 20 people.
And in January, at least 19 people were killed by a bomb strapped to a girl aged about 10 in Maiduguri.
Maiduguri is where Boko Haram first emerged, and the Nigerian military has recently begun moving its headquarters from the capital Abuja to the city.
African news updates
Nigeria's female bombers
Boko Haram militants have killed at least 40 people in north-eastern Nigeria, according to witnesses.