I thought I understood it in my head, but I can't get it right.
I thought I had a mental understanding of it, but I really didn't.
この場合、次のように言うと良いでしょう。
ーI thought I understood it in my head, but I can't get it right.
「頭ではわかってるつもりだけど、うまくできない」
I thought I understood it in my head, ... を使って表現できます。
ーI thought I had a mental understanding of it, but I really didn't.
「頭の中ではわかっているつもりだけど、わかってなかったみたい」
I thought I had a mental understanding of it, ... のようにも表現できます。
ご参考まで!