The parent of track owner Magna Entertainment Corp. has agreed to buy its Maryland assets, which include Laurel Park and Pimlico.