If you want to place blocks on linear entities but the amount may differ you can use 'Multiple Divide Random'. You can specify a minimum and a maximum amount of segments. For every linear element the command will pick a random amount of segments between that minimum and maximum. You can also activate the option to place blocks on the end of the selected linear entities so two additional blocks are added on the start and endpoint of the linear entity.