The internet and the World Wide Web are not the same thing, and the internet came first.
The internet is the underlying global network of connected computers, and it traces back to ARPANET, a US Department of Defense project that first linked computers together in 1969. The World Wide Web, by contrast, is a system of linked documents that runs on top of that network, and it wasn’t invented until 1989-1991, by Tim Berners-Lee at CERN.
By the time the Web arrived, the internet had already been carrying email, file transfers, and other traffic for two decades. The Web simply gave it a much more accessible, visual way for ordinary people to navigate and publish information, which is why it’s often mistaken for the internet itself rather than one application running on top of it.