Conceptually, why is adding a scalar to a matrix defined ins some cases when adding matrices of different dimensions does not seem to make sense? What does it mean to add a dot to a line, or a line to a square, or a square to a cube, or a dot or line or square to a cube? An answer in words is fine. I tried the following and am still having trouble picturing what is going on.
Note: This question is NOT about the mechanics of Octave. It is about understanding the space of what adding between dimensions means if it means anything at all. By example Octave defined its own way described below, and Feynman defined his own math a child. Are there any useful conventions in adding between dimensions, and if so, what are they and why are they useful?
An answer on this thread suggests implicitly using the identity matrix to add a scalar to a matrix. However Octave and MATLAB do not behave that way. Instead they behave as if adding a scalar to a matrix is like multiplying a matrix of all ones by the scalar and then adding that result to the original matrix.
By example Octave lets you add the scalar, 1, to a matrix of different size even though it treats a scalar as a matrix of size 1x1. Notice how the results for A+1 and A+eye(2) differ and how A+eye(3) fails.
octave:1> A=eye(2)
A =
Diagonal Matrix
1 0
0 1
octave:2> A+1
ans =
2 1
1 2
octave:3> A+eye(2)
ans =
Diagonal Matrix
2 0
0 2
octave:4> A+eye(3)
error: operator +: nonconformant arguments (op1 is 2x2, op2 is 3x3)
octave:4> size(1)
ans =
1 1
This answer suggests that trailing singleton dimensions do not count. Meaning
octave:5> A(2,1,1)
ans = 0
Given that why does A+eye(3) fail? What does A(2,1,1) mean for a 2x2 matrix?
This answer suggests when adding vectors of different dimensions of the shorter vector could be padded with zeros in undefined dimensions. It then talks about some kind of infinite vector space which I am having trouble picturing. It suggests something like the following is possible even though it seems nonsensical to me. And, as expected, it does not work in Octave.
octave:6> A(1,1)=eye(2)
error: =: nonconformant arguments (op1 is 1x1, op2 is 2x2)
The answer is a bit nuanced. In mathematics you can define whatever you want. Georg Cantor wrote (in German) "The essence of mathematics lies entirely in its freedom." So, for example, you could define the addition of any two matrices of any size. Same thing holds in defining any programming language. The pragmatic questions are "What is the point of the definition? What kind of purposes can it be used for? What useful properties does it have? Does it lead to any ontradictions?" This freedom allows that there can be many different possible definitions of something, and some of them may be equivalent to other definitions, but do not have to be, and that can lead to ambiguities and confusion. What usually happens is that a lot of decisions are made for convenience reasons, particularly in programming languages which are less constrained than pure mathematics.
For the particular questions that you asked, it seems to be that the designers of the programming languages you mentioned thought it would be convenient to design the operations the way they did. It need not be consistent with more conventional mathematical choices as long as they are being documented clearly. Perhaps in time, the abuse of notation $A-\lambda$ instead of $A-\lambda I$ will win.