Structural Stability, Electronic, Magnetic, and Optical Properties of Rectangular Graphene and Boron Nitride Quantum Dots: Effects of Size, Substitution, and Electric Field