This effect is very easy to produce in Unity using a couple of Box Colliders, and some basic math. The effect will ressemble the following:

This is a very simple model for this problem. First you need 3 gameobjects added to your scene. Each object will contain a BoxCollider2D and a RigidBody2D with gravity removed.
The blue boxes just have a simple update method to move them in a static direction, for the purpose of the demo.
The orange box, checks if a collision is currently occurring. If it is colliding, Unity automatically stops the objects from overlapping each other, as they already have a BoxCollider2D attached.
The only thing you need to do, is determine if the box is being pushed on both sides. If it is only being pushed on one side, then do nothing. If it is being pushed on both ends at the same time, then you adjust the size of the box, while retaining its total area.
So to start, calculate the total area of your orange box:
public float Area;
bool PushedLeft, PushedRight;
float ForceLeft, ForceRight;
void Start () {
Area = transform.localScale.x * transform.localScale.y;
}
Then, determine if it is being pushed on both ends at the same time:
void OnCollisionStay2D(Collision2D coll) {
//Check all points of contacts occuring on this object
for (int i = 0; i < coll.contacts.Length; i++) {
//Is the collision occuring to the left of box?
if (this.transform.position.x > coll.contacts[i].point.x)
{
//Is it pushing in? or pulling out?
Vector2 diff = coll.contacts[i].point - coll.contacts[i].normal;
if (diff.x < 0)
{
PushedLeft = true;
ForceLeft = 0.1f;
}
}
//collision occuring to the right of box
else if (this.transform.position.x < coll.contacts[i].point.x)
{
//Is it pushing in? or pulling out?
Vector2 diff = coll.contacts[i].point - coll.contacts[i].normal;
if (diff.x < 0)
{
PushedRight = true;
ForceRight = 0.1f;
}
}
}
}
Then, if it is being pushed on both ends, Squeeze it so that it alters its shape:
void Update () {
//Adjust box if being squeezed
if (PushedLeft && PushedRight) {
float squeezeForce = ForceLeft + ForceRight;
float x = transform.localScale.x - squeezeForce * Time.deltaTime;
float y = Area / x;
transform.localScale = new Vector2 (x, y);
}
}
Hoping this helps out someone else that would like to figure out this problem.
Vector3.Distance
and assign it to X-Scale of the victim object ;). And at the same time assign 1/distance to the Y scale. Hope it helps \$\endgroup\$