A lot happens between verses 14-26, so we need to understand that to see the context.
Jesus as the giver of bread
Perceiving then that they were about to come and take him by force to make him king, Jesus withdrew again to the mountain by himself.
Jesus was not on earth to be forced into being a political king (or rebel). This was not what Jesus or the Father wanted, it is what the people wanted (Luke 24:19-27).
After this Jesus sends the disciples across the Sea of Galilee ahead if him and then we have the famous Jesus walking on water incident where Jesus tells them "it is I; do not be afraid."
In the morning the people realize Jesus is gone, John 6:24-25
24 So when the crowd saw that Jesus was not there, nor his disciples, they themselves got into the boats and went to Capernaum, seeking Jesus.
25 When they found him on the other side of the sea, they said to him, “Rabbi, when did you come here?”
Here we see that Jesus in vs26 (AND 27) is answering their question:
26.Jesus answered them, “Truly, truly, I say to you, you are seeking me, not because you saw signs, but because you ate your fill of the loaves.
27 Do not work for the food that perishes, but for the food that endures to eternal life, which the Son of Man will give to you. For on him God the Father has set his seal.”
Jesus is pointing out that their desire for him is not coming from a true desire for the things of God but for a desire from their own bellies.
Jesus As the bread
This can be taken literally, as he just fed then until they were full the day before, but also figuratively:
Their end is destruction, their god is their belly, and they glory in their shame, with minds set on earthly things.
And oppositely, Matthew 5:6,
“Blessed are those who hunger and thirst for righteousness, for they shall be satisfied.
The people were focused on earthly things, on an earthly king and on earthly bread. They may have believed he was the one to come, but their view on who was to come was wrong.
And after this account in John 6 we see Jesus try to explain it to the Disciples:
35 Jesus said to them, “I am the bread of life; whoever comes to me shall not hunger, and whoever believes in me shall never thirst.
51 I am the living bread that came down from heaven. If anyone eats of this bread, he will live forever. And the bread that I will give for the life of the world is my flesh.”
The theme of John 6 is Jesus as the bread of life, the mana, the Passover bread and drink (we see in John 6:6 that this was actually the Passover meal).
There is no contradiction. The people believed, earnestly, he was the one to come and wanted him to give them what they wanted and do what they expected. But they were wrong about what he would do and what they needed.
Jesus knew that what they needed was not earthly bread or an earthly king, but bread and a king from heaven.