Salim El Koudri, a 31-year-old man, born in Italy and of Moroccan origin, drove a car into a crowd in the city centre on Saturday, injuring eight people, four of them seriously.
The man attempted to flee and stabbed one of three passers-by who tried to stop him.
He was later arrested by police.
Modena's prosecutors said in a statement on Sunday that the suspect is under investigation for attempted massacre and personal injury.
They said the man struck pedestrians in the crowded city centre, which has more than 180,000 residents, "in an indiscriminate, random and deliberate manner".
Among those seriously injured, two lost their legs and one was in a life-threatening condition, the prosecutors added.
Meloni cancelled a meeting in Nicosia with Cyprus' president in order to travel to Modena alongside Mattarella, government sources said, asking not to be named.
Attacks using vehicles to drive into crowds have become increasingly common worldwide.
Some have been ranked as terror attacks.
The Italian prosecutors said only they were seeking to establish El Koudri's motives.
Italy's Deputy Prime Minister Matteo Salvini, who leads the anti-immigrant League party, on Sunday called in a post on X for the revocation of residence permits for those who commit crimes.
Massimo Mezzetti, the mayor of Modena, said that two Egyptian citizens were among those who tried to stop El Koudri as he attempted to flee.
Speaking on broadcaster RaiNews24, he also said El Koudri had been treated for mental health issues in the past.
He also said he held a degree in economics and was unemployed.
Prosecutors have not confirmed these details.
They also could not be reached to confirm reports that a Polish woman and a German woman were among the injured.