Functions are called in weird order

hello....i have written a code but doesnt work as expected . I have two functions in my program that are RecieveMessage() and serialEvent() . i have called these two functions in void setup 1)RecieveMessage() and then 2)serialEvent(). when i run my program, first my serialEvent fuction is operating then my ReceiveMessage function. so i want to know how functions are called in arduino
thanks

#include <SoftwareSerial.h>
//use TX to 9 and RX to 10
SoftwareSerial mySerial(9, 10);


void setup()
{
  mySerial.begin(9600);   // Setting the baud rate of GSM Module  
  Serial.begin(9600);    // Setting the baud rate of Serial Monitor (Arduino)
  delay(100);
  
RecieveMessage();
serialEvent();
 }


void loop()
{
  
 if (mySerial.available()>0)
   Serial.write(mySerial.read());


  }

 void RecieveMessage()
{
  mySerial.println("AT+CNMI=2,2,0,0,0"); // AT Command to receive a live SMS
  delay(1000);
  mySerial.println("GSM SUCCESSFULLY CONFIGURED FOR RECEIVING");
  delay(1000);
 }
 
 void serialEvent()
{
   Serial.println(Serial.available());
 
}

Output :

0
AT+CNMI=2,2,0,0,0

OK
GSM SUCCESSFULLY CONFIGURED FOR RECEIV

Expected Output is

AT+CNMI=2,2,0,0,0

OK
GSM SUCCESSFULLY CONFIGURED FOR RECEIV
0

they will be executed in this order RecieveMessage(); serialEvent();

try this:

Serial.println("Start Receive");

RecieveMessage();

Serial.println("End Receive");

Serial.println("Start serial");

serialEvent();

Serial.println("End serial");

i have interface my gsm and arduino, communication between gsm and arduino is good, when I send message to gsm module it is displayed on serial monitor but when i try to save message in a string and display that string it doesn't work. can you please tell me where my message is stored in arduino when you receive it and how to extract that message

Can you please tell me how can i do it??

thanks

Maybe something like this will help. Not tested but should work.

//put this in loop and use the serial you want to read
while(Serial.available()>0)
  {
    processIncomingByte(Serial.read());
  } 

//picked this up from Mr.G

const byte MAXIN = 150;
void processIncomingByte(const byte inbyte)
{
   static char gsmline [MAXIN];
   static unsigned int gsmpos = 0;
  
  if(inbyte=='\n')// this char is the last byte change to whatever you need - only one char
  { 
    gsmline [gsmpos] = 0;  // null byte        
    Serial.println(gsmline);// do something with the data
    gsmpos = 0; // reset buffer      
  }
  else
  {      
    if (gsmpos < (MAXIN - 1))//anything over MAXIN bytes, before \n received, is dumped  -1 for null byte
    {                
      gsmline [gsmpos++] = inbyte;  //save byte       
    }     
  }   
} // end processIncomingByte