The Bible cannot contradict itself. Mark and Luke will mean that the forty days belong to the temptations because Christ became very hungry during that time and this made him more susceptible to the temptations. Matthew focuses on the main part of the temptation: when Satan came to Jesus after forty days.
3 And the tempter came and said to him, “If you are the Son of God, command these stones to become loaves of bread.”