@kmh42 Children only inherit lower title as per primogeniture if the person who gets elected to inherit the top tier title is of a different dynasty. If the elected heir is of the same dynasty as the previous holder they will also inherit all lower titles. In this case the empire was held by a Karling and inherited by another Karling so that one got the duchy as well.
Additionally, if a title is ever granted to someone it's succession law will be reset to the most basic one available based on religion and government type. For feudal Christians that is agnatic-cognatic gavelkind.
The alliance thing appears to be a bug. I suggest reporting it in the
Bug Reports subforum.