If you don’t purchase from Apple, or an Apple Authorised Retailer, there are no guarantees that your Apple-branded products are the genuine article - and this applies to just about anything you purchase through independent retailers.
Apple will only have record of devices purchased directly from Apple. Items purchased through other sources are unlikely to have any information recorded by Apple - unless an additional AppleCare+ plan for the product has since been purchased from Apple.
While Apple’s online resources may be unable to validate provenance, if you have purchased your Magic Keyboard from a reputable retailer you should have no immediate cause for concern. If you are concerned for product provenance, you should always purchase from an Authorised Retailer.