Enemy Prefab Instances behaving Incorrectly?

Alright, so I have an enemy prefab with everything set up.
When I place said prefab into the scene manually, it behaves perfectly.
The enemy is supposed to be able to detect the normal of a wall in front of it, and then rotate to that normal, allowing it to walk up the wall.

As you can see here, the manually placed prefab does the job, and runs up the Wall.

However, when the prefab is instantiated, the enemy doesn’t detect the normal correctly, and awkwardly jitters up the wall instead.

Here is the code in question:

        Ray ray = new Ray(transform.position, -transform.up);
        RaycastHit info = new RaycastHit();
        Ray forwardRay = new Ray(transform.position - new Vector3(0,.5f,0), model.transform.forward);
        RaycastHit forwardInfo = new RaycastHit();
        Quaternion rotationGoal = Quaternion.Euler(0, 0, 0);

            if (Physics.Raycast(forwardRay, out forwardInfo, 7f))
            {
            Debug.Log("Noticed wall!");
            rotationGoal = Quaternion.Lerp(transform.rotation, Quaternion.FromToRotation(Vector3.up, forwardInfo.normal), animCurve.Evaluate(Time.deltaTime * 4));
            transform.rotation = Quaternion.Euler(rotationGoal.eulerAngles.x, transform.rotation.eulerAngles.y, rotationGoal.eulerAngles.z);
            anim.SetBool("Falling", false);
            rigidBody.AddForce(model.transform.forward * speed, ForceMode.VelocityChange);
            }
            else if (Physics.Raycast(ray, out info, 7f))
            {
                Grounded = true;
                rotationGoal = Quaternion.Lerp(transform.rotation, Quaternion.FromToRotation(Vector3.up, info.normal), animCurve.Evaluate(Time.deltaTime));
                transform.rotation = Quaternion.Euler(rotationGoal.eulerAngles.x, transform.rotation.eulerAngles.y, rotationGoal.eulerAngles.z);
                anim.SetBool("Falling", false);
            rigidBody.AddForce(model.transform.forward * speed, ForceMode.VelocityChange);
                dustParticle.Play();
            }
            else
            {
            rigidBody.AddForce(model.transform.forward * .25f, ForceMode.VelocityChange);
            dustParticle.Stop();
                Grounded = false;
                anim.SetBool("Falling", true);
                rotationGoal = Quaternion.Lerp(transform.rotation, Quaternion.FromToRotation(Vector3.up, Vector3.up), animCurve.Evaluate(Time.deltaTime));
                transform.rotation = Quaternion.Euler(rotationGoal.eulerAngles.x, transform.rotation.eulerAngles.y, rotationGoal.eulerAngles.z);
            }

Any ideas for why something like this would happen? I’m pulling my hair out here trying to get to the bottom of this.

I have found the issue.
As it turns out, the script that was spawning the instances of the Prefab was doing so with a random rotation. In this case, the random rotation at the time of creation led to the instance being confused as to what was “Up”, leading to problems when the instance attempted to rotate itself.

If anyone ends up having a similar problem, where a Prefab functions properly but misbehaves as an instance, I would suggest looking into the Context and Circumstances in which the instance is being created.