The Phrase Doctor gives both the meaning and apparent origins of the phrase, writing that:
Meaning A kindred spirit - someone I can agree with.
Further, this meaning is by most accounts from the King James version of the Bible.
Based on this meaning--that it means "a kindred spirit"--then after seems to take on this rarer meaning listed in the OED:
- In compliance with the wishes of.
c1395 Chaucer Wife of Bath's Tale 406 And eek I pray to Jhesus schort her lyves, That wil nought be governed after her wyves [6– text bi].
a1500 (1460) Towneley Plays (1994) I. xxii. 278 Pylate, do after vs, And dam to deth Iesus.
As these examples were written both before and after the King James Bible (which was written in 1611), this is likely the same use of after as was found there.
The OED also explains that the use of heart here is one that is now obsolete, meaning:
Intent, will, purpose, inclination, desire. Obs. exc. in phr. after one's own heart.
So to be after one's own heart means that someone is in compliance with one's own intent, will, or inclination. This, in current use, is the same as being "someone I can agree with". To be in compliance with one's own will means that someone is in agreement with one's own will.