problem with LED matrix and raspberry pi
My question is, Is this "trick" actually a good trick? is this how major programs related to LED matrix are done? or is there any other ways to do so? If there is, please explain in simplicity.


You have done what is called Scanning a Multiplex Display. Due to the shared pin setup of Columns and Rows of a Matrix, you will find it Ghosts if multiple pins are enabled at the same time. This is called Ghosting and happens in not only simple LED display matrixes, but Multiplexed Displays, LCDs,  even Keyboards (Microsoft article on Keyboard Ghosting)


  "Ghosting" is the problem that some keyboard keys don't work when multiple keys are pressed simultaneously. The key presses that don't show up on the computer or seem to have disappeared are said to have been "ghosted". On most keyboards, even some that are explicitly marketed as "Anti-Ghosting," this happens with many three key combinations.


Your Trick, as mentioned, is called scanning. By alternating which row and column are on, so only one is on at any given time, there is no conflict. If done faster than human vision can process (30 times per second (Hertz or Hz) if they are not moving their eyes/heads, but smoother at 60 Hz, and recommended faster than 100 Hz), you take advantage of the phenomenon called Persistence of Vision. Your trick is how all multiplex displays are handled, with some variations.

An Application Note by a leading semiconductor producer on how to avoid ghosting and other common issues. This is targeted to professional engineers but is very informative if you want to learn more.

An alternative to doing this directly, in your code, or even in drivers as the OS for the RPI might block access due to cpu usage, is offloading this to a dedicated LED Display Driver IC. The only difference is that the IC was developed to do the same scanning more efficiently, freeing your main processor from having to keep track of the display.

Additionally, the RPI is not meant to drive much current on it's GPIO pins. A larger display, or one that has LEDs that require more current, will not work well. LED Display Driver ICs tend to support much higher current than the 16mA max per pin of the RPI. But your example of a single color 8x8 display with only 1 led on at a time will be fine.