Actually it all have to do with aspiration, e.g a small puff of air coming out when saying the sound. Or in the case with ก , it is a k without any air coming out is probably the most accurate description but writing g is therefore closer then a real k that have aspiration. :) You can test this yourself with holding your hand in front of your mouth saying english k and then stop any air from coming out. There you have the correct sound for ก