How does the scholar of ahlulbayt come up with a book of certain subject
Is the basis is their own opinion and explanation or it is directly an explanation of the Imams towards an certain subject. For example if I read the book about aqaid does the content of the book be possibly based in opinion of the author?

Depends on the authors style of writing. But ultimately his opinions should have their roots in Quran and narrations.