How to create a plane that follows the dimensions of an object?
Instead of using the dimensions property, create your own bounding box.


Create a list of the vertex positions matmultiplied by the objects world matrix. This list will hold the coordinates of the vertices in world space.
Get the min and max of the x and y property of the coordinate list.






def createPlane(context):

    obj = context.object
    coordinates = [obj.matrix_world @ v.co for v in obj.data.vertices]

    x_list = [co.x for co in coordinates]
    y_list = [co.y for co in coordinates]

    x_min, x_max = min(x_list), max(x_list)
    y_min, y_max = min(y_list), max(y_list)

    verts = ((x_min, y_min, 0),(x_min, y_max, 0),
             (x_max, y_max, 0),(x_max, y_min,0))

    bm = bmesh.new()
    [bm.verts.new((v[0], v[1], v[2])) for v in verts]
    bm.faces.new(bm.verts)

    bm.normal_update()

    me = bpy.data.meshes.new("")
    bm.to_mesh(me)

    plane = bpy.data.objects.new("", me)
    bpy.context.scene.collection.objects.link(plane)