Yes, they are grammatically correct and we can and do express ownership in those ways.
We would use “mayroon” or “may” if the actor or the thing being described is the subject of the sentence. For example:
AKO ay may/mayroong sampung lapis. = May sampung lapis AKO. = Mayroon AKOng sampung lapis. = I have ten pencils. - “Ako” is the subject.
IKAW ba ay may/mayroong dalawang libro? = May dalawang libro KA ba? = Mayroon KA bang dalawang libro? = Do you have two books. - “Ikaw/ka” is the subject.
In the two sentences you mentioned, however, the subject is the OBJECT or the thing that someone has. Literally, they would translate to:
Sampu ang lapis ko. = Ten are my pencils. = My pencils are ten. = Ang lapis ko ay sampu. - The subject is “my pencils”.
Dalawa ba ang libro mo? = Two are your books? = Your books are two? = Ang libro mo ba ay dalawa? - The subject is “your books”.
Although the preceding English translations sound unnatural, their Tagalog counterparts don’t. That’s because it is not uncommon for us to use the object as the subject of the sentence. That’s what the Tagalog object-focus verbs are for.
Moreover, the English translations no longer use the verb “to have”, but “be” instead. English requires the use of the “be” verb, but since Tagalog does not have that verb, our sentences still make sense to us without it. The “ay” is sometimes considered the equivalent of “be”, but it is only there when the sentence is expressed in the form of the English active voice.
Notice also that in the last two sentences above where the object is the subject of the sentence, “ko” and “mo” are used instead of “ako” and “ikaw”. “Ko” and “mo” are possessive pronouns and that’s how “having something” or “doing something (as the actor of the verb)” gets expressed when the subject is the object.
Therefore, the textbook is not wrong.
Are you going crazy? Well, I don’t have the qualifications to assess that. 😅😅