What do Buddhists think in quick prayers (at graves, near altars etc.)? When declared Buddhists and Eastern Asians in general quickly pray next to graves and altars in silence, what kinds of thoughts go on their minds? Of course, it's not possible to read people's minds, but how are they taught to pray  in such occasions and places?  I'm curious especially about non-practicing Buddhists who aren't very religious in general and may not know things like mantras by heart, but still do that.
I'm not Eastern Asian but I'd guess that the brahmaviharas would be appropriate -- including e.g. "may you be well", and mudita in the form of "recollection of virtue".



I've read that a common phrase is ...


  Anicca vata sankhara — "Impermanent, alas, are all formations!" — is the phrase used in Theravada Buddhist lands to announce the death of a loved one [but I have not quoted this line here in order to begin an obituary].


You said you didn't want a mantra but here is a longer quote -- it's not very long.


  
    Aniccā vatha sankhārā
    Uppāda vaya dhamminō
    Uuppajjitvā nirujjhanti
    Te san vūpa samō sukhō
    
    (Mahā Parinibbāna Sutta)
  
  
  This verse is actually not in the Dhammapada, but it is a very common verse. In Sri Lanka (and possibly in other Buddhist countries), it is displayed at funerals in order to emphasize the “fleeting nature” of life. It actually has a much deeper meaning, and explains why we face sorrow inevitably (because death is inevitable), and how it can be permanently removed to attain the Nibbānic bliss.
  
  This verse is said to have been uttered by Sakka, the King of the Dēvas, just after the Parinibbāna (passing away) of the Buddha.
  
  A common translation is:
  
  
    All things are impermanent
    They arise and pass away
    Having arisen they come to an end
    Their coming to peace is bliss
  




I don't know whether there are "prayers" as a Western theist (e.g. "Abrahamic religion") might understand that word -- see e.g. Paccha-bhumika Sutta (SN 42.6) -- so I think it's a person's own virtue that's important, rather than intercessionary prayer -- though there are different schools of Buddhism, some of whom pray (e.g. here) though perhaps not for the same reason as a theist.

I think it is common too (in some cultures anyway) to make some offerings to ghosts -- there's a popular ghost festival. I'm not sure but I think that the Theravada teaches that the "ghost realm" is one of the states (of suffering) into which someone way be reborn, and that the only way they can eat there is if someone is kind enough to remember to share their food with them.