From Middle Dutch cacken, probably from Latin cacō (“to defecate, soil”), either way presumably ultimately sound imitative.
Practice speaking and memorizing "kakken" and many other words and sentences in Dutch.