These are not sentences, just groups of words. Depending on the rest of the sentence, one might be better than the other, but without more context, they're equal.
Sorry, I wrote sentence instead of 'phrases or group of words'
I give you some contexts: 'These explanations are in grammar books/ in books on grammar' According to the rules of grammar/ grammar rules, what you've written is incorrect.
I also say books on grammar, but I want to know if the other prhases are correct too.
A grammar book contains all the technical aspects of grammar for whatever language it covers. A book about grammar could just be a book about the history of grammar or the differences between grammar in different languages, for example. It would probably give a few examples but it would not be the kind of book a learner would need in order to study the grammar of a specific language.