When you visit a website, your computer sends a request to a computer elsewhere to ask for that specific web page. This other computer then sends back the web page that you asked for. This other computer is called a web server, or short a server.
Chat apps also use web servers. If you send a message, this message is first sent to the server. The server then passes it along to the device of your recipient. The server may also store other data, such as analytics of how often you use your chat app. What kind of pieces of information are stored, how long they remain on the web server and how they are encrypted, depends on the chat app you use and their privacy and security practices.